package com.example.userblog.controller;

import cn.hutool.core.date.DateUtil;
import com.example.userblog.common.Result;
import com.example.userblog.entity.Article;
import com.example.userblog.service.ArticleService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("article")
public class ArticleController {
    @Resource
    ArticleService articleService;
    @PostMapping("list")
    public Result getData(@RequestParam(defaultValue = "1") Integer page,@RequestParam(defaultValue = "5") Integer size){

        return Result.success(articleService.getAll(page,size));
    }
    @PostMapping("add")
    public Result addArticle(@RequestBody Article article){
        article.setCreateTime(DateUtil.now());
        return Result.success(articleService.add(article));

    }
}
